package com.ihr360.excel.utils;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;

public class SpreadSheetConvertResultUtil {


    public static Object ByteToObject(byte[] bytes) throws IOException, ClassNotFoundException {
        Object obj = null;
        try (ByteArrayInputStream bi = new ByteArrayInputStream(bytes);
             ObjectInputStream oi = new ObjectInputStream(bi)) {
            obj = oi.readObject();
        }
        return obj;
    }

    public static byte[] ObjectToByte(java.lang.Object obj) throws IOException {
        byte[] bytes = null;
        try (ByteArrayOutputStream bo = new ByteArrayOutputStream();
             ObjectOutputStream oo = new ObjectOutputStream(bo);) {
            oo.writeObject(obj);
            bytes = bo.toByteArray();
        }
        return bytes;
    }

}
